package com.wushi.lenovo.asia5b.app_widget.bottomtab;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.animation.Animation;
import android.view.animation.ScaleAnimation;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.wushi.lenovo.asia5b.R;

/**
 * Created by zhangyuncai on 2019/11/6.
 * 主页底部带"批"字的tabView
 */
public class WAlphaPiView extends LinearLayout {
    //底部tab文字
    TextView tv_pi_text;
    //右上角 "批"
    TextView tv_pi_new;
    //底部icon
    ImageView iv_pi_icon;

    public WAlphaPiView(Context context) {
        super(context);
        init();
    }

    public WAlphaPiView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public WAlphaPiView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        LayoutInflater.from(getContext()).inflate(R.layout.view_alphapi, this, true);
        tv_pi_text = findViewById(R.id.tv_pi_text);
        tv_pi_new = findViewById(R.id.tv_pi_new);
        iv_pi_icon = findViewById(R.id.iv_pi_icon);
        ScaleAnimation animation = new ScaleAnimation(1, 1.3f, 1, 1.3f, Animation.RELATIVE_TO_SELF,0f, Animation.RELATIVE_TO_SELF,1f);
        animation.setRepeatMode(Animation.REVERSE);
        animation.setInterpolator(new PiLinearInterpolator());
        animation.setRepeatCount(Animation.INFINITE);
        animation.setDuration(400);
        tv_pi_new.startAnimation(animation);
    }

    @Override
    public void setSelected(boolean selected) {
        super.setSelected(selected);
        tv_pi_text.setSelected(selected);
        iv_pi_icon.setSelected(selected);
    }
}
